package tq.com.tqcom.vh;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class CommonViewHolder extends RecyclerView.ViewHolder {
    static public CommonViewHolder sCommonViewHolder(Context pContext, int res, ViewGroup p){
        View lView = LayoutInflater.from(pContext).inflate(res, p, false);
        return new CommonViewHolder(lView);
    }
    public CommonViewHolder(View pView){
        super(pView);
    }

    public CommonViewHolder setHolderBinder(IViewHolder pViewHolder){
        mIViewHolder = pViewHolder;
        return this;
    }
    public CommonViewHolder setClickListener(View.OnClickListener pOnClickListener){
        itemView.setOnClickListener(pOnClickListener);
        return this;
    }

    public void bindData(Object d){
        mIViewHolder.bind(itemView, d);
    }


    private IViewHolder mIViewHolder;
    public interface IViewHolder{
        void bind(View pView, Object data);
    }
}
